import Taro, { Component } from '@tarojs/taro'
import {View, Input, Button, Picker} from '@tarojs/components'
import { AtList, AtListItem } from 'taro-ui'
import qs from 'qs'

export default class attendance extends Component {

  config = {
    navigationBarTitleText: this.state.title
  };

  constructor (props) {
    super(props);
    this.state = {
      title: '工资详情',
      advanceBonus: "", //预发奖金
      basicWage: "", //基本工资
      bonus: "", //奖金
      communicationSubsidy: "", //通讯补贴
      competitionAllowance: "", //竞业津贴
      deductionAfterTax: "", //税后扣款
      deductionOfAdvanceBonus: "", //补扣预发奖金
      endowmentInsurance: "", //养老保险
      medicalInsurance: "", //医保
      month: "",
      netWage: "", //纯粹工资
      others: "", //其他
      overtimePay: "", //加班工资
      paidInSalary: "", //实发工资
      performancePay: "", //绩效工资
      personalIncomeTax: "", //个人所得税
      providentFund: "", //公积金
      salaryPayable: "", //应发工资
      sociaSecurityAllowance: "", //补充社保津贴
      socialSecurityAllowance: "", //社保津贴
      titleAllowance: "", //职称津贴
      totalDeduction: "", //扣款合计
      transportationSubsidy: "", //交通补贴
      unemploymentInsurance: '', //失业保险
    }
  }

  componentDidMount () {
    let array = window.location.hash.split('?');
    if (array.length>1){
      let obj = qs.parse(array[1]);
      let detailData = JSON.parse(obj.detailData);
      this.setState({...detailData, title: `${detailData.month}工资明细`})
    }
  }

  render () {
    let { ...data } = this.state;
    return (
      <View className='fontSize'>
        <AtList>
          <AtListItem title='基本工资' extraText={data.basicWage && parseFloat(data.basicWage).toFixed(2)} />
          <AtListItem title='绩效工资' extraText={data.performancePay && parseFloat(data.performancePay).toFixed(2)} />
          <AtListItem title='竞业津贴' extraText={data.competitionAllowance && parseFloat(data.competitionAllowance).toFixed(2)} />
          <AtListItem title='社保津贴' extraText={data.socialSecurityAllowance && parseFloat(data.socialSecurityAllowance).toFixed(2)} />
          <AtListItem title='加班工资' extraText={data.overtimePay && parseFloat(data.overtimePay).toFixed(2)} />
          <AtListItem title='通讯补贴' extraText={data.communicationSubsidy && parseFloat(data.communicationSubsidy).toFixed(2)} />
          <AtListItem title='交通补贴' extraText={data.transportationSubsidy && parseFloat(data.transportationSubsidy).toFixed(2)} />
          <AtListItem title='职称津贴' extraText={data.titleAllowance && parseFloat(data.titleAllowance).toFixed(2)} />
          <AtListItem title='补充社保津贴' extraText={data.sociaSecurityAllowance && parseFloat(data.sociaSecurityAllowance).toFixed(2)} />
          <AtListItem title='奖金' extraText={data.bonus && parseFloat(data.bonus).toFixed(2)} />
          <AtListItem title='预发奖金' extraText={data.advanceBonus && parseFloat(data.advanceBonus).toFixed(2)} />
          <AtListItem title='其他' extraText={data.others && parseFloat(data.others).toFixed(2)} />
          <AtListItem title='应发工资' extraText={data.salaryPayable && parseFloat(data.salaryPayable).toFixed(2)} />
          <AtListItem title='养老保险' extraText={data.endowmentInsurance && parseFloat(data.endowmentInsurance).toFixed(2)} />
          <AtListItem title='医保' extraText={data.medicalInsurance && parseFloat(data.medicalInsurance).toFixed(2)} />
          <AtListItem title='失业保险' extraText={data.unemploymentInsurance && parseFloat(data.unemploymentInsurance).toFixed(2)} />
          <AtListItem title='公积金' extraText={data.providentFund && parseFloat(data.providentFund).toFixed(2)} />
          <AtListItem title='个人所得税' extraText={data.personalIncomeTax && parseFloat(data.personalIncomeTax).toFixed(2)} />
          <AtListItem title='补扣预发奖金' extraText={data.deductionOfAdvanceBonus && parseFloat(data.deductionOfAdvanceBonus).toFixed(2)} />
          <AtListItem title='税后扣款' extraText={data.deductionAfterTax && parseFloat(data.deductionAfterTax).toFixed(2)} />
          <AtListItem title='扣款合计' extraText={data.totalDeduction && parseFloat(data.totalDeduction).toFixed(2)} />
          <AtListItem title='纯粹工资' extraText={data.netWage && parseFloat(data.netWage).toFixed(2)} />
          <AtListItem title='实发工资' extraText={data.paidInSalary && parseFloat(data.paidInSalary).toFixed(2)} />
        </AtList>
      </View>
    )
  }
}
